package com.oazon.moco.link.serialport;

import java.util.Arrays;

import org.apache.http.protocol.ResponseServer;

import android.util.Log;

import com.oazon.moco.link.bean.Mcu;
import com.oazon.moco.link.core.LinkEvent;
import com.oazon.moco.link.core.LinkEventListener;
import com.oazon.moco.link.core.source.LinkEventSource;
import com.oazon.moco.link.event.ResponceEvent;
import com.oazon.moco.link.event.ResponceStatus;
import com.oazon.moco.serialport.SerialSend;

public class ResponceEventListener extends LinkEventListener {

	public ResponceEventListener(LinkEventSource... sources) {
		setBlackList(Arrays.asList(sources));
	}

	@Override
	public void onLinkEvent(LinkEvent event) {
		if (filter((LinkEventSource)event.getSource())
				|| !(event instanceof ResponceEvent)) {
			return;
		}
		ResponceEvent e = (ResponceEvent) event;

		if (e.getResponceStatus() == ResponceStatus.NORMAL) {
			SerialSend.getInstance().sendStatus(SerialSend.Serial_WAKE);
			
		} else if (e.getResponceStatus() == ResponceStatus.SLEEP) {
			SerialSend.getInstance().sendStatus(SerialSend.Serial_SLEEPING);
			
		} else if (e.getResponceStatus() == ResponceStatus.SHUTDONW) {
			SerialSend.getInstance().sendStatus(SerialSend.Serial_SHUTDOWN);
			
		} else if (e.getResponceStatus() == ResponceStatus.OPENDOWN) {
			SerialSend.getInstance().sendStatus(SerialSend.Serial_OPEN);
			
		} else if (e.getResponceStatus() == ResponceStatus.VOLUME) {
			SerialSend.getInstance().sendVolume(e.getVolume().getMaster());
		}else if(e.getResponceStatus().equals(ResponceStatus.HARDWARE_VERSION)){
			Mcu.mcu_verison=e.getHardwareVersion();
			Log.i("iiiiiiiiiiii",e.getHardwareVersion());
		}
		
		
		
		
		
		System.out.println("McuFindEvent is" + e.getResponceStatus());
	}
}
